package com.itheima.ydd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.ydd.common.PageResult;
import com.itheima.ydd.entity.YddLink;
import com.itheima.ydd.mapper.YddLinkMapper;
import com.itheima.ydd.service.YddLinkService;
import org.springframework.stereotype.Service;

@Service
public class YddLinkServiceImpl extends ServiceImpl<YddLinkMapper, YddLink> implements YddLinkService {
    /**
     * 分页条件查询
     * @param type
     * @param page
     * @param limit
     * @return
     */
    @Override
    public PageResult getList(String type, Long page, Long limit) {
        //分页构造器
        Page<YddLink> pageInfo = new Page(page,limit);
        //查询条件
        LambdaQueryWrapper<YddLink> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(YddLink::getType,type);
        this.page(pageInfo, queryWrapper);
        return PageResult.init(pageInfo.getTotal(),page,limit,pageInfo.getRecords());
    }
}
